using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VBAAUF
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "TST":
                case "UBT":
                default:
                    #region=========
                    dwReturn["BAMANDANT"] = "00";
                    dwReturn["BAAUFTYP"] = "V";
                    dwReturn["BAAUFKRS"] = "  ";
                    dwReturn["BAAUFLFD"] = "000000";
                    dwReturn["BAAUFPOS"] = "000";
                    dwReturn["BASA"] = "733";
                    dwReturn["BAPOS"] = "0000";
                    dwReturn["BAAFOLGE"] = "000";
                    dwReturn["BADATVON"] = "0";
                    dwReturn["BADATBIS"] = "0";
                    dwReturn["BAKART"] = "                    ";
                    dwReturn["BAKVAR"] = "01";
                    dwReturn["BAKFARBE"] = "          ";
                    dwReturn["BAMTR1"] = "0";
                    dwReturn["BAANZ1"] = "1";
                    dwReturn["BAMTR2"] = "0";
                    dwReturn["BAANZ2"] = "0";
                    dwReturn["BAMTR3"] = "0";
                    dwReturn["BAANZ3"] = "0";
                    dwReturn["BAMTR4"] = "0";
                    dwReturn["BAANZ4"] = "0";
                    dwReturn["BAMTR5"] = "0";
                    dwReturn["BAANZ5"] = "0";
                    dwReturn["BAMTR6"] = "0";
                    dwReturn["BAANZ6"] = "0";
                    dwReturn["BAMTR7"] = "0";
                    dwReturn["BAANZ7"] = "0";
                    dwReturn["BAERLKZ"] = " ";
                    dwReturn["BABAUMART"] = "      ";
                    dwReturn["BADRKZ"] = "0";
                    dwReturn["BADISPOKZ"] = "B";
                    dwReturn["BALO"] = "  ";
                    dwReturn["BALB"] = "  ";
                    dwReturn["BALP"] = "        ";
                    dwReturn["BAAUFBKZ"] = " ";
                    dwReturn["BAURKVAR"] = "01";
                    dwReturn["BAAENDZL"] = "0";
                    dwReturn["BAAENDBEN"] = "        ";
                    dwReturn["BAAENDDAT"] = "0";
                    dwReturn["BANEUBEN"] = "        ";
                    dwReturn["BANEUDAT"] = "0";
                    dwReturn["BADOMKZ"] = "D";
                    dwReturn["BABASMG"] = "0";
                    dwReturn["BALLEIST"] = "    ";
                    dwReturn["BARLEIST"] = "    ";
                    dwReturn["BASCHIENE"] = "     ";
                    dwReturn["BATLPOS"] = "00";
                    dwReturn["BAINFOKZ"] = " ";
                    dwReturn["BAVARKZ"] = " ";
                    dwReturn["BATLSA"] = "   ";
                    dwReturn["BAABF2"] = "0";
                    dwReturn["BAZBEDKG"] = "0";
                    dwReturn["BAZBEDMTR"] = "0";
                    dwReturn["BAFILLER"] = "                                                 "; 
                    #endregion
                    break;
                case "JLT":
                    #region=========
                    #endregion
                    break;
            }
        }
 
        public void InsertBAAUF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            dwData["BANEUBEN"] = app.User;
            dwData["BANEUDAT"] = date;
            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                default:
                case "SXN":
                case "TST":
                case "UBT":
                case "YGR":
                    or1.CommandText = "INSERT INTO BAAUF ( BAMANDANT,BAAUFTYP,BAAUFKRS,BAAUFLFD,BAAUFPOS,BASA,BAPOS,BAAFOLGE,BADATVON,BADATBIS,BAKART,BAKVAR,BAKFARBE,BAMTR1,BAANZ1,BAMTR2,BAANZ2,BAMTR3,BAANZ3,BAMTR4,BAANZ4,BAMTR5,BAANZ5,BAMTR6,BAANZ6,BAMTR7,BAANZ7,BAERLKZ,BABAUMART,BADRKZ,BADISPOKZ,BALO,BALB,BALP,BAAUFBKZ,BAURKVAR,BAAENDZL,BAAENDBEN,BAAENDDAT,BANEUBEN,BANEUDAT,BADOMKZ,BABASMG,BALLEIST,BARLEIST,BASCHIENE,BATLPOS,BAINFOKZ,BAVARKZ,BATLSA,BAABF2,BAZBEDKG,BAZBEDMTR,BAFILLER)"
                    + " VALUES (:BAMANDANT:,:BAAUFTYP:,:BAAUFKRS:,:BAAUFLFD:,:BAAUFPOS:,:BASA:,:BAPOS:,:BAAFOLGE:,:BADATVON:,:BADATBIS:,:BAKART:,:BAKVAR:,:BAKFARBE:,:BAMTR1:,:BAANZ1:,:BAMTR2:,:BAANZ2:,:BAMTR3:,:BAANZ3:,:BAMTR4:,:BAANZ4:,:BAMTR5:,:BAANZ5:,:BAMTR6:,:BAANZ6:,:BAMTR7:,:BAANZ7:,:BAERLKZ:,:BABAUMART:,:BADRKZ:,:BADISPOKZ:,:BALO:,:BALB:,:BALP:,:BAAUFBKZ:,:BAURKVAR:,:BAAENDZL:,:BAAENDBEN:,:BAAENDDAT:,:BANEUBEN:,:BANEUDAT:,:BADOMKZ:,:BABASMG:,:BALLEIST:,:BARLEIST:,:BASCHIENE:,:BATLPOS:,:BAINFOKZ:,:BAVARKZ:,:BATLSA:,:BAABF2:,:BAZBEDKG:,:BAZBEDMTR:,:BAFILLER:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
      
        public DataSet QBAAUF01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM BAAUF  "
               + " WHERE BAMANDANT=:BAMANDANT: AND BAAUFTYP=:BAAUFTYP: AND BAAUFKRS =:BAAUFKRS: AND BAAUFLFD=:BAAUFLFD: AND BAAUFPOS=:BAAUFPOS: AND BASA=:BASA:  AND BAPOS=:BAPOS:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBAAUF02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM BAAUF  "
               + " WHERE BAMANDANT=:BAMANDANT: AND BAAUFTYP=:BAAUFTYP: AND BAAUFKRS =:BAAUFKRS: AND BAAUFLFD=:BAAUFLFD: AND BAAUFPOS=:BAAUFPOS: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBAAUF03(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT M.* FROM BAAUF M "
               + " WHERE BAMANDANT=:BAMANDANT: AND BAAUFTYP=:BAAUFTYP: AND BAAUFKRS =:BAAUFKRS: AND BAAUFLFD=:BAAUFLFD: AND BAAUFPOS=:BAAUFPOS: AND BASA=:BASA: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBAAUF04(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM BAAUF  "
               + " WHERE BAMANDANT=:BAMANDANT: AND BAAUFKRS =:BAAUFKRS: AND BAAUFLFD=:BAAUFLFD:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void DBAAUF01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();

            or1.CommandText = "DELETE FROM BAAUF  "
                       + " WHERE     BAMANDANT=:BAMANDANT: AND BAAUFTYP=:BAAUFTYP: AND BAAUFKRS =:BAAUFKRS: AND BAAUFLFD=:BAAUFLFD: AND BAAUFPOS=:BAAUFPOS: AND BASA=:BASA:  AND BAPOS=:BAPOS:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
             
            Connect2Proxy(or1);
        }

        public void UpdateBAAUF(DataRow dwData, string ITXDBVERSION = "50.24", int option = 1)
        {
           
            
           if(option==0)
            {
                switch(app.company)
                {
                    default:
                    case "SXN":
                    case "TST":
                    case "UBT":
                    case "YGR":
                        UBAAUF01(dwData);
                        break;

                }
            }  
        }
        public void UBAAUF01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE BAAUF SET BAMANDANT=:BAMANDANT:,BAAUFTYP=:BAAUFTYP:,BAAUFKRS=:BAAUFKRS:,BAAUFLFD=:BAAUFLFD:,BAAUFPOS=:BAAUFPOS:,BASA=:BASA:,BAPOS=:BAPOS:,BAAFOLGE=:BAAFOLGE:,BADATVON=:BADATVON:,BADATBIS=:BADATBIS:,BAKART=:BAKART:,BAKVAR=:BAKVAR:,BAKFARBE=:BAKFARBE:,BAMTR1=:BAMTR1:,BAANZ1=:BAANZ1:,BAMTR2=:BAMTR2:,BAANZ2=:BAANZ2:,BAMTR3=:BAMTR3:,BAANZ3=:BAANZ3:,BAMTR4=:BAMTR4:,BAANZ4=:BAANZ4:,BAMTR5=:BAMTR5:,BAANZ5=:BAANZ5:,BAMTR6=:BAMTR6:,BAANZ6=:BAANZ6:,BAMTR7=:BAMTR7:,BAANZ7=:BAANZ7:,BAERLKZ=:BAERLKZ:,BABAUMART=:BABAUMART:,BADRKZ=:BADRKZ:,BADISPOKZ=:BADISPOKZ:,BALO=:BALO:,BALB=:BALB:,BALP=:BALP:,BAAUFBKZ=:BAAUFBKZ:,BAURKVAR=:BAURKVAR:,BAAENDZL=:BAAENDZL:,BAAENDBEN=:BAAENDBEN:,BAAENDDAT=:BAAENDDAT:,BANEUBEN=:BANEUBEN:,BANEUDAT=:BANEUDAT:,BADOMKZ=:BADOMKZ:,BABASMG=:BABASMG:,BALLEIST=:BALLEIST:,BARLEIST=:BARLEIST:,BASCHIENE=:BASCHIENE:,BATLPOS=:BATLPOS:,BAINFOKZ=:BAINFOKZ:,BAVARKZ=:BAVARKZ:,BATLSA=:BATLSA:,BAABF2=:BAABF2:,BAZBEDKG=:BAZBEDKG:,BAZBEDMTR=:BAZBEDMTR:,BAFILLER=:BAFILLER: "
                              + " WHERE  BAMANDANT=:BAMANDANT: AND BAAUFTYP=:BAAUFTYP: AND BAAUFKRS =:BAAUFKRS: AND BAAUFLFD=:BAAUFLFD: AND BAAUFPOS=:BAAUFPOS: AND BASA=:BASA:  AND BAPOS=:BAPOS:";

            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }
    }
}
